<!-- 打印当前页 -->
<template>
  <div>
    <button
      ref="printbtn"
      class="printCurrentPage"
      v-print="'#printCurrentPage'"
    ></button>
    <div id="printCurrentPage" class="nocalssvw">
      <!-- <div> -->
        <img
          :src="
            imgIndex !== null && list[imgIndex]
              ? list[imgIndex].description
              : ''
          "
          alt=""
          style="width: 100%; height: 100%"
        />
      <!-- </div> -->
    </div>
  </div>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => [],
      required: true,
    },
    imgIndex: {
      type: Number,
    },
  },
  data() {
    return {
      myPrint: {
        id: "printCurrentPage",
        extarCss: "",
      },
    };
  },
  created() {},
  methods: {
    print() {
      this.$refs["printbtn"].click();
    },
  },
};
</script>
    <style>
@page {
  size: auto;
  margin: 0;
}
</style>
    <style scoped lang="scss">
.myprintbtn {
  display: none;
}
#printCurrentPage {
  position: fixed;
  min-width: 645px;
  left: 900000px;
  // page-break-after: always;
  width: 210mm;
  padding:10mm;
  img{
    width: 210mm;
    height: 297mm;
    page-break-after: avoid; /* 避免分页 */
  }
}
@media print {
  #printCurrentPage {
    position: static;
    min-width: 100%;
    page-break-after: auto;
    width: 210mm;
    padding: 10mm;
  }
}
</style>